import { axios } from '@/utils/request'

/**
 * 分页查询流程模型列表
 * @param query
 * @returns {*}
 */
export function pageModel(query) {
  return axios({
    url: '/workflow/model/page',
    method: 'get',
    params: query
  })
}

/**
 * 分页查询流程历史模型列表
 * @param query
 * @returns {*}
 */
export function historyModel(query) {
  return axios({
    url: '/workflow/model/historyList',
    method: 'get',
    params: query
  })
}

/**
 * 获取流程模型详细信息
 *
 * @param modelId 模型主键
 */
export function getModel(modelId) {
  return axios({
    url: '/workflow/model/' + modelId,
    method: 'get'
  })
}

/**
 * 新增流程模型
 * @param data
 * @returns {*}
 */
export function addModel(data) {
  return axios({
    url: '/workflow/model',
    method: 'post',
    data: data
  })
}

/**
 * 修改模型信息
 * @param data
 * @returns {*}
 */
export function updateModel(data) {
  return axios({
    url: '/workflow/model',
    method: 'put',
    data: data
  })
}

/**
 * 保存流程模型xml
 * @param data
 * @returns {*}
 */
export function saveModel(data) {
  return axios({
    url: '/workflow/model/save',
    method: 'post',
    data: data
  })
}

/**
 * 设为最新流程模型
 * @param params
 * @returns {AxiosPromise}
 */
export function latestModel(params) {
  return axios({
    url: '/workflow/model/latest',
    method: 'post',
    params: params
  })
}

/**
 * 删除流程模型
 * @param modelIds
 * @returns {AxiosPromise}
 */
export function delModel(modelIds) {
  return axios({
    url: '/workflow/model/' + modelIds,
    method: 'delete'
  })
}

/**
 * 部署流程模型
 * @param params
 * @returns {AxiosPromise}
 */
export function deployModel(params) {
  return axios({
    url: '/workflow/model/deploy',
    method: 'post',
    params: params
  })
}

/**
 * 配置流程模型
 * @param modelId
 * @param appType
 * @returns {AxiosPromise}
 */
export function configModel(modelId, appType) {
  return axios({
    url: '/workflow/model/config/' + modelId + '/' +  appType,
    method: 'post'
  })
}

/**
 * 查询流程图xml
 * @param modelId
 * @returns {*}
 */
export function getXml(modelId) {
  return axios({
    url: '/workflow/model/getXml/' + modelId,
    method: 'get'
  })
}
